package com.sinping.qh.query.records;

import com.sinping.qh.query.base.Operator;
import com.sinping.qh.query.base.QueryParams;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 隐患记录查询
 *
 * @author Tiansx
 * @create 2018-06-05 17:01
 **/
@Data
public class HiddenDangerRecordQuery implements QueryParams,Serializable {

    private static final long serialVersionUID = 6272982787926992164L;
    static Map<String, String> aliasMap = new HashMap<>();
    static Map<String, Operator> operatorMap = new HashMap<>();

    /**
     * 检查院系id
     */
    private String checkUnitId;

    /**
     * 检查楼宇id
     */
    private String checkBuildingId;

    /**
     * 检查时间，开始
     */
    private Date startDate;

    /**
     * 检查时间，结束
     */
    private Date endDate;

    /**
     * 记录状态
     */
    private String checkStatus;

    /**
     * 所属所室
     */
     private String offices;

    /**
     * 隐患状态
     */
     private String hiddenDangerStatus;
    /**
     * 隐患状态集合
     */
    private List<String>hidden_danger_status;
    /**
     * 检查记录id
     */
    private String checkId;
    static {
        aliasMap.put("checkUnitId", "check_unit_id");
        aliasMap.put("checkBuildingId", "check_building_id");
        aliasMap.put("checkStatus","check_status");
        aliasMap.put("startDate", "check_date");
        aliasMap.put("endDate", "check_date");
        aliasMap.put("offices","offices");
        aliasMap.put("hiddenDangerStatus","hidden_danger_status");
        aliasMap.put("checkId","check_id");
        aliasMap.put("hidden_danger_status","hidden_danger_status");

        operatorMap.put("checkUnitId", Operator.eq);
        operatorMap.put("checkBuildingId", Operator.eq);
        operatorMap.put("checkStatus",Operator.eq);
        operatorMap.put("startDate",Operator.gte);
        operatorMap.put("endDate", Operator.lte);
        operatorMap.put("offices",Operator.regex);
        operatorMap.put("hiddenDangerStatus",Operator.eq);
        operatorMap.put("checkId",Operator.eq);
        operatorMap.put("hidden_danger_status", Operator.in);


    }

    @Override
    public String getAlias(String fieldName) {
        return aliasMap.getOrDefault(fieldName, fieldName);
    }

    @Override
    public Operator getOperators(String fieldName) {
        return operatorMap.getOrDefault(fieldName, Operator.eq);
    }



}
